package com.hongxun.project.assets.Tools;

import com.lowagie.text.*;

import java.io.IOException;

/**
 * Created by admin on 2018/7/16.
 */
public class OutPutUtils {

    public static void  addcell(Table table, String value, int hang , int lie, boolean iscenter, Font contextFont ) throws BadElementException {
        if (value == null) {
            value = "";
        }
        Cell cell1 = new Cell(new Phrase(value + "", contextFont));
        if (iscenter) {
            cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);

        }


        if (hang > 0) {
            cell1.setRowspan(hang);
        }
        if (lie > 0) {
            cell1.setColspan(lie);
        }

        table.addCell(cell1);
    }

    public static void addcellimg(Table table,String value, int hang ,int lie,boolean iscenter,Font contextFont ) throws BadElementException, IOException {

        Cell cell1 = new Cell();
        Image img = Image.getInstance(value);
        img.setAbsolutePosition(0, 0);
        img.scaleAbsolute(120, 150);// 直接设定显示尺寸


        cell1.add(img);
        if (iscenter) {
            cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);

        }


        if (hang > 0) {
            cell1.setRowspan(hang);
        }
        if (lie > 0) {
            cell1.setColspan(lie);
        }

        table.addCell(cell1);
    }

}
